using System.Drawing;
using Microsoft.VisualStudio.Modeling;
using Microsoft.VisualStudio.Modeling.Diagrams;

namespace Microsoft.Modeling.StoryboardDesigner
{
    /// <summary>
    /// Description for the new MultiLineCompartment shape
    /// </summary>
    /// <remarks>The description includes the delegates to get and set the display
    /// value for the compartment, and the minimum height in lines of the compartment.</remarks>
    public class MultiLineCompartmentDescription : CompartmentDescription
    {
        private MultiLineCompartment.GetDisplayValueDelegate _getValueDelegate;
        private MultiLineCompartment.SetDisplayValueDelegate _setValueDelegate;

        private int _minHeightInLines;
        private bool _defaultExpanded;

        #region Constructor
        public MultiLineCompartmentDescription(
            string name, 
            string title, 
            System.Drawing.Color titleFill, 
            bool allowCustomTitleFillColor, 
            Color compartmentFill, 
            bool allowCustomCompartmentFillColor, 
            FontSettings titleFontSettings,
            MultiLineCompartment.GetDisplayValueDelegate getValueDelegate,
            MultiLineCompartment.SetDisplayValueDelegate setValueDelegate,
            int minHeightInLines,
            bool defaultExpanded)
            : base(name, title, titleFill, allowCustomTitleFillColor, compartmentFill, allowCustomCompartmentFillColor, titleFontSettings)
        {
            _getValueDelegate = getValueDelegate;
            _setValueDelegate = setValueDelegate;
            _minHeightInLines = minHeightInLines;
            _defaultExpanded = defaultExpanded;
        }

        #endregion

        #region Accessors

        public MultiLineCompartment.GetDisplayValueDelegate GetValueDelegate
        {
            get { return _getValueDelegate; }
        }

        public MultiLineCompartment.SetDisplayValueDelegate SetValueDelegate
        {
            get { return _setValueDelegate; }
        }

        public int MinimumHeightInLines
        {
            get { return _minHeightInLines; }
        }

        #endregion

        public override Compartment CreateCompartment(Store store)
        {
            // Create the new compartment
            MultiLineCompartment comp = new MultiLineCompartment(store);

            // Set whether expanded by default
            comp.IsExpanded = _defaultExpanded;

            comp.UpdateSize();

            comp.Invalidate();

            // return the newly-created compartment
            return comp;
        }
    }
}